//
//  BaseViewController.m
//  FloatClouds
//
//  Created by 黄威 on 16/8/25.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "BaseViewController.h"

@implementation BaseViewController
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    
    if (self) {
        NSUserDefaults *nightIsOn = [NSUserDefaults standardUserDefaults];
        NSString *isOn = [nightIsOn objectForKey:@"night"];
        
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(ON)
                                                     name:@"NIGHTON"
                                                   object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(OFF)
                                                     name:@"NIGHTOFF"
                                                   object:nil];
        // self.navigationBar.translucent = NO;
        
        if ([isOn isEqualToString:@"0"]) {
            
            self.view.backgroundColor = [UIColor whiteColor];
            
            
            
        }else if([isOn isEqualToString:@"1"]){
            
            self.view.backgroundColor = [UIColor colorWithRed:93/255.0 green:92/255.0 blue:101/255.0 alpha:1];
            
        }
        
    }
    return self;
    
}
- (void)ON{
    
    self.view.backgroundColor =  [UIColor colorWithRed:93/255.0 green:92/255.0 blue:101/255.0 alpha:1];
    
    
}

- (void)OFF{
    //lanse
    self.view.backgroundColor =[UIColor whiteColor];
    
    
}
- (void)dealloc{
    
    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NIGHTON" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NIGHTOFF"object:nil];
    
    
}


@end
